<template>
  <div>
    <li v-for="(item, index) in arr" :key="item">
      {{ item }}
      <button @click="remove" :value="index">删除</button>
    </li>
    <button @click="bulid">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [1, 5, 1],
    }
  },
  methods: {
    remove(e) {
      let num = e.target.value
      this.arr.splice(num, 1)
    },
    bulid() {
      this.arr.push(Math.floor(Math.random() * 100))
    },
  },
}
</script>

<style></style>
